//
//  AnimationBoot.swift
//  SwiftUIWidgetDemo
//
//  Created by alanzhangg on 2023/7/14.
//

import SwiftUI

struct AnimationBoot: View {
    
    @State var isAnimation: Bool = false
    
    var body: some View {
        VStack{
            Button("Button") {
                withAnimation(Animation
                    .easeInOut) {
                    isAnimation.toggle()
                }
                
            }
            Spacer()
            RoundedRectangle(cornerRadius: isAnimation ? 50 : 25)
                .fill(isAnimation ? .red : .green)
                .frame(
                    width: isAnimation ? 100 : 300,
                    height: isAnimation ? 100 : 300)
                .rotationEffect(Angle(degrees: isAnimation ? 360 : 0))
                .offset(y: isAnimation ? 300 : 0)
            
            Spacer()
            
        }
    }
}

#Preview {
    AnimationBoot()
}
